package com.mexico.inloancash.utils;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;

/**
 * Created by Eric at 2021/3/26
 */
public class SmsUtils {

    private SmsUtils() {
    }

    public static void getAllSms(Context context) {
        Log.d("loan", "获取短信");
        ContentResolver cr = context.getContentResolver();
        String[] projection = new String[]{"_id", "address", "person", "body", "date", "type"};
        Cursor cur = cr.query(Uri.parse("content://sms/"), projection, null, null, "date desc");
        if (null == cur) {
            Log.i("loan", " cur is null");
            return;
        }

        while (cur.moveToNext()) {
            String number = cur.getString(cur.getColumnIndex("address"));//手机号
            String name = cur.getString(cur.getColumnIndex("person"));//联系人姓名列表
            String body = cur.getString(cur.getColumnIndex("body"));//短信内容
            String smsTime = cur.getString(cur.getColumnIndex("date"));//短信时间
            String type = cur.getString(cur.getColumnIndex("type"));
        }
    }
}
